package com.shujia.mllib

import org.apache.spark.ml.classification.LogisticRegressionModel
import org.apache.spark.ml.linalg
import org.apache.spark.ml.linalg.Vectors
import org.apache.spark.sql.SparkSession

object Demo3PersonpPro {
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession
      .builder()
      .master("local")
      .appName("person")
      .getOrCreate()

    import spark.implicits._
    import org.apache.spark.sql.functions._


    /**
      * 加载模型
      *
      */

    val model: LogisticRegressionModel = LogisticRegressionModel.load("Spark/data/model")


    /**
      * 构建新的数据
      *
      */

    /**
      * 预测
      * transform：批量预测
      * predict;; 单条预测
      *
      */


    /**
      * 1:5.4 2:4.0 3:3.0 4:135.6 5:88.6 6:70.1 7:72
      */


    val xs: linalg.Vector = Vectors.dense(5.4, 4.0, 3.0, 135.6, 88.6, 70.1, 72)


    val y: Double = model.predict(xs)


    println(y)


  }
}
